package com.ruoyi.web.controller.report;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.report.ExamSurvey;
import com.ruoyi.system.service.report.IExamSurveyService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 随访表Controller
 *
 * @author jiadun
 * @date 2022-01-03
 */
@RestController
@RequestMapping("/report/ExamSurvey")
public class ExamSurveyController extends BaseController
{
    @Autowired
    private IExamSurveyService examSurveyService;

    /**
     * 查询随访表列表
     */
    @PreAuthorize("@ss.hasPermi('report:ExamSurvey:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExamSurvey examSurvey)
    {
        startPage();
        List<ExamSurvey> list = examSurveyService.selectExamSurveyList(examSurvey);
        return getDataTable(list);
    }

    /**
     * 导出随访表列表
     */
    @PreAuthorize("@ss.hasPermi('report:ExamSurvey:export')")
    @Log(title = "随访表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExamSurvey examSurvey)
    {
        List<ExamSurvey> list = examSurveyService.selectExamSurveyList(examSurvey);
        ExcelUtil<ExamSurvey> util = new ExcelUtil<ExamSurvey>(ExamSurvey.class);
        util.exportExcel(response, list, "随访表数据");
    }

    /**
     * 获取随访表详细信息
     */
    @PreAuthorize("@ss.hasPermi('report:ExamSurvey:query')")
    @GetMapping(value = "/{surveyid}")
    public AjaxResult getInfo(@PathVariable("surveyid") Long surveyid)
    {
        return AjaxResult.success(examSurveyService.selectExamSurveyBySurveyid(surveyid));
    }

    /**
     * 新增随访表
     */
    @PreAuthorize("@ss.hasPermi('report:ExamSurvey:add')")
    @Log(title = "随访表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExamSurvey examSurvey)
    {
        return toAjax(examSurveyService.insertExamSurvey(examSurvey));
    }

    /**
     * 修改随访表
     */
    @PreAuthorize("@ss.hasPermi('report:ExamSurvey:edit')")
    @Log(title = "随访表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExamSurvey examSurvey)
    {
        return toAjax(examSurveyService.updateExamSurvey(examSurvey));
    }

    /**
     * 删除随访表
     */
    @PreAuthorize("@ss.hasPermi('report:ExamSurvey:remove')")
    @Log(title = "随访表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{surveyids}")
    public AjaxResult remove(@PathVariable Long[] surveyids)
    {
        return toAjax(examSurveyService.deleteExamSurveyBySurveyids(surveyids));
    }
}
